// 父类
export default class BaseService{

    /**通过传参，对变量赋值
     * @param {Object} _vueRef
     */
  baseInit(_vueRef,ajaxObj) {
      BaseService.prototype.vueRef=_vueRef;
      BaseService.prototype.ajaxObj= ajaxObj;
      //第一次this是有的
      BaseService.prototype.that =this;
       

      // 动态绑到组件中去
      BaseService.prototype.vueRef.handleCurrentChange=this.handleCurrentChange;
      BaseService.prototype.vueRef.handleSizeChange =this.handleSizeChange;
      BaseService.prototype.vueRef.search =this.search;
      
      //加载分页数据
      BaseService.prototype.that.getData();
    }
    
    //查询
    search() {
      BaseService.prototype.that.handleCurrentChange(1)
    }

 // 每页几笔发生变化
 handleSizeChange(val) {
    BaseService.prototype.vueRef.formSearch.pageNumber = 1
    BaseService.prototype.vueRef.formSearch.pageSize = val
    BaseService.prototype.that.getData()
 }

  // 当前第几页
 handleCurrentChange(val) {
   BaseService.prototype.vueRef.formSearch.pageNumber = val
    BaseService.prototype.that.getData()
 }

 getData(){
   BaseService.prototype.ajaxObj.getData(BaseService.prototype.vueRef.formSearch).then( resp => {
     BaseService.prototype.vueRef.tableData = resp.data.data
     BaseService.prototype.vueRef.total = resp.data.total
   }).catch( e=> {
     console.log(e)
   })
 }

}
